#include "SpriteNode.h"

mtBEGIN(SpriteNodeDef)
	mtBASE(SceneNodeDef);
	mtCONSTRUCTOR();
	mtVARIABLE(sprite);
	mtVARIABLE(scale);
mtEND

mtBEGIN(SpriteNode)
	mtBASE(SceneNode);
	mtCONSTRUCTOR();
	mtMETHOD(initWith);
mtEND

bool SpriteNode::initWith( SpriteNodeDef* def )
{
	SceneNode::initWith(def);

	_sprite = cocos2d::CCSprite::create(def->sprite.c_str());

	if (def->scale.hasValue())
		_sprite->setScale(def->scale);

	getNode()->addChild(_sprite);
	return true;
}

void SpriteNode::onDestroy()
{
	CC_SAFE_RELEASE_NULL(_sprite);
	SceneNode::onDestroy();
}
